package dex.studio.compose.news.ui

import android.graphics.drawable.Icon
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.sp
import dex.studio.compose.news.R
import dex.studio.compose.news.ui.theme.ComposeNewsColor

@Composable
fun NewsTopAppBar(title: String, isShowBack: Boolean, onClickBack: () -> Unit={}) {
    TopAppBar(title = {
        Text(
            text = title,
            fontFamily = FontFamily.Cursive,
            fontSize = 24.sp,
            color = Color.White
        )
    }, backgroundColor = ComposeNewsColor.MainColor, navigationIcon = {
        if (isShowBack) {
            //只有详情页才会有返回按钮
            IconButton(onClick = onClickBack) {
                Icon(
                    painter = painterResource(id = R.drawable.ic_jetnews_logo),
                    contentDescription = "back"
                )
            }
        }
    })
}